package com.springboot.controller;

import com.springboot.Service.BookService;
import com.springboot.entity.Book;
import com.springboot.utils.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "提供了查询、增加等相关的接口",tags = "图书管理")
@CrossOrigin
@RestController
public class BookController {
    @Resource
    private BookService bookService;
    @RequestMapping(value = "/bookList",method = RequestMethod.GET)
    @ApiOperation("查询分页接口")
    public ResultVO showList(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return bookService.bookList(name, pageNum);
    }


    @RequestMapping(value = "/addBook",method = RequestMethod.POST)
    @ApiOperation("书籍新增接口")
    public ResultVO addBook(Book book){
        return bookService.addBook(book);
    }


    @RequestMapping(value = "/deleteBook",method = RequestMethod.GET)
    @ApiOperation("用户删除接口")
    public ResultVO deleteBook(long bid){
        return bookService.deleteBook(bid);
    }

    @RequestMapping(value = "/saveBook",method = RequestMethod.GET)
    @ApiOperation("书籍修改接口")
    public ResultVO saveBook(Book book){
        return bookService.saveBook(book);
    }
}
